﻿#include "FrameHeader.h"

void SerializeTest::test()
{
	SerializerBitWrite writer;
	writer.writeBool(true);
	writer.writeSigned(1);
	writer.writeSigned(-1);
	writer.writeSigned(0);
	writer.writeSigned(1231243125);
	writer.writeSigned(0x7FFFFFFF);
	writer.writeFloat(1.2f);
	writer.writeFloat(-2.2f);
	writer.writeDouble(2.2222);
	writer.writeUnsigned(1u, 2u, 10u);
	writer.writeUnsigned(0u);
	writer.writeUnsigned(1u);
	writer.writeUnsigned(2u);
	writer.writeUnsigned(0xFFFFFFFF);
	writer.writeSigned(1, 2, -10);
	writer.writeSignedList(Vector<int>{ 1, 2, 3, 123123123 });
	writer.writeSignedList(Vector<int>{ 0, 0, 0, 0 });
	writer.writeUnsignedList(Vector<uint>{ 0, 0, 0, 0 });
	writer.writeUnsignedList(Vector<uint>{ 1, 2, 3, 123123123 });
	writer.writeSignedList(Vector<short>{ 1, 2, 3 });
	writer.writeSignedList(Vector<llong>{ 1, 2, 3 });
	writer.writeUnsignedList(Vector<byte>{ 1, 2, 3 });
	writer.writeFloatList(Vector<float>{ 1.5f, 2.5f, 3.5f });
	writer.writeFloatList(Vector<float>{ 1.5f, 2.5f, 312312.5f, 0.0f, 1.0f });
	writer.writeDoubleList(Vector<double>{ 1.555, 2.555, 3.555 });
	writer.writeDoubleList(Vector<double>{ 1.5, 2.5, 312312.51, 0.0, 1.0 });
	writer.writeDoubleList(Vector<double>{ });
	writer.writeSignedList(Vector<char>{ 1, 2, -3});

	SerializerBitRead reader(writer.getBuffer(), writer.getByteCount());
	bool value0;
	int value1;
	int value2;
	int value3;
	int value30;
	int value31;
	float value4;
	float value5;
	double value6;
	uint value7;
	uint value7_0;
	uint value7_1;
	uint value7_2;
	uint value8;
	uint value9;
	uint value90;
	int value90_0;
	int value90_1;
	int value90_2;
	Vector<int> list0;
	Vector<int> list00;
	Vector<uint> list01;
	Vector<uint> list02;
	Vector<short> list1;
	Vector<llong> list2;
	Vector<byte> list3;
	Vector<float> list4;
	Vector<float> list40;
	Vector<double> list5;
	Vector<double> list50;
	Vector<double> list6;
	Vector<char> list7;
	reader.readBool(value0);
	reader.readSigned(value1);
	reader.readSigned(value2);
	reader.readSigned(value3);
	reader.readSigned(value30);
	reader.readSigned(value31);
	reader.readFloat(value4);
	reader.readFloat(value5);
	reader.readDouble(value6);
	reader.readUnsigned(value7_0, value7_1, value7_2);
	reader.readUnsigned(value7);
	reader.readUnsigned(value8);
	reader.readUnsigned(value9);
	reader.readUnsigned(value90);
	reader.readSigned(value90_0, value90_1, value90_2);
	reader.readSignedList(list0);
	reader.readSignedList(list00);
	reader.readUnsignedList(list01);
	reader.readUnsignedList(list02);
	reader.readSignedList(list1);
	reader.readSignedList(list2);
	reader.readUnsignedList(list3);
	reader.readFloatList(list4);
	reader.readFloatList(list40);
	reader.readDoubleList(list5);
	reader.readDoubleList(list50);
	reader.readDoubleList(list6);
	reader.readSignedList(list7);

	llong mTargetGUID = 0;
	llong mSkillFireTimeStamp = 1718813086792;
	Vector<float> mFloatParam{4163, 4155, 2};
	bool mTargetIsMonster = false;
	float mAttackSpeed = 2.05f;
	float mAttackStateTime = -1.0f;
	int mSkillID = 27;
	int mDamageToken = 1;

	SerializerBitWrite writer0;
	writer0.writeSigned(mTargetGUID, mSkillFireTimeStamp);
	writer0.writeFloatList(mFloatParam);
	writer0.writeBool(mTargetIsMonster);
	writer0.writeFloat(mAttackSpeed, mAttackStateTime);
	writer0.writeSigned(mSkillID, mDamageToken);

	SerializerBitRead reader0(writer0.getBuffer(), writer0.getByteCount());
	reader0.readSigned(mTargetGUID, mSkillFireTimeStamp);
	reader0.readFloatList(mFloatParam);
	reader0.readBool(mTargetIsMonster);
	reader0.readFloat(mAttackSpeed, mAttackStateTime);
	reader0.readSigned(mSkillID, mDamageToken);
}